﻿<%@ Page Title="" Language="VB" MasterPageFile="~/Views/Shared/Base.Master" Inherits="System.Web.Mvc.ViewPage(Of DailyReport.UserCheckReportModel)" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    UserCheckReport
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <% 
        Dim allbusiness = ""
        Dim level1data = ""
        For Each c As DailyReport.UserCheckReportItem In Model.UserCheckReportItems
            allbusiness += String.Concat(c.Business, ",")
            level1data += String.Concat(c.Level1, ",")
        Next
        allbusiness = allbusiness.Substring(0, allbusiness.Length - 1)
        level1data = level1data.Substring(0, level1data.Length - 1)
        
        Dim startDate As Date
        Dim endDate As Date
        '月 显示上个月的情况

        'If Now.Day <= 26 Then
        '    startDate = Date.Parse(Now.AddMonths(-1).ToString("yyyy-MM") + "-26")
        '    endDate = Date.Parse(Now.AddMonths(0).ToString("yyyy-MM") + "-27")
        'Else
        '    startDate = Date.Parse(Now.AddMonths(0).ToString("yyyy-MM") + "-26")
        '    endDate = Date.Parse(Now.AddMonths(1).ToString("yyyy-MM") + "-27")
        'End If
        Dim inDate As Date = Now
        
        If inDate.Day <= 28 Then
            If inDate.Month = 3 Then
                If (Date.Parse(inDate.ToString("yyyy-MM") + "-1")).AddDays(-1).Day = 29 Then
                    startDate = New Date(inDate.Year, inDate.AddMonths(-1).Month, 29)
                Else
                    startDate = New Date(inDate.Year, inDate.Month, 1)
                End If
            Else
                startDate = Date.Parse(inDate.AddMonths(-1).ToString("yyyy-MM") + "-29")
            End If
            endDate = Date.Parse(inDate.ToString("yyyy-MM") + "-28")
        Else
            startDate = Date.Parse(inDate.ToString("yyyy-MM") + "-29")
            endDate = Date.Parse(inDate.AddMonths(1).ToString("yyyy-MM") + "-28")
        End If

    %>
    <script type="text/javascript" language="javascript">
        var _rangestart = new Date('<%= startDate.toString("MM/dd/yyyy")%>');
        var _rangeend = new Date('<%= endDate.toString("MM/dd/yyyy")%>');
        var _currenrUserName = '<%=DailyReport.DailyReportCommon.CurrentUserName %>';

        var tcategories = '<%= allbusiness%>';
        var acategories = tcategories.split(',');
        var tlevel1data = '<%= level1data%>';
        var alevel1data = tlevel1data.split(',');

        for (i = 0; i < alevel1data.length; i++) {
            alevel1data[i] = Number(alevel1data[i]);
        }
    </script>
    <ext:Viewport ID="ViewPort1" runat="server" Layout="fit">
        <Items>
            <ext:Panel ID="Panel1" runat="server" Header="false" Border="false">
                <TopBar>
                    <ext:Toolbar ID="toolbar1" runat="server">
                        <Items>
                            <%--<ext:SelectBox ID="sltRange" runat="server" DisplayField="text" ValueField="value">
                                <Store>
                                    <ext:Store runat="server" ID="dcRange">
                                        <Proxy>
                                            <ext:HttpProxy runat="server" Url="/Setting/ReportRange.xml" />
                                        </Proxy>
                                        <Reader>
                                            <ext:XmlReader Record="item">
                                                <Fields>
                                                    <ext:RecordField Name="value" Mapping="@value" />
                                                    <ext:RecordField Name="text" Mapping="@text" />
                                                </Fields>
                                            </ext:XmlReader>
                                        </Reader>
                                        <Listeners>
                                            <Load Handler="sltRange.selectFirst();" />
                                        </Listeners>
                                    </ext:Store>
                                </Store>
                                <Listeners>
                                    <Select Fn="" />
                                </Listeners>
                            </ext:SelectBox>--%>
                            <%--<ext:Label ID="Label1" runat="server" Text="统计：从&nbsp;">
                            </ext:Label>
                            <ext:DateField ID="drFrom" runat="server" Vtype="daterange" AnchorHorizontal="100%" Format="yyyy-MM-dd">
                                <Listeners>
                                    <Render Handler="item.setValue(_rangestart);" />
                                    <Change Handler="_rangestart = newValue;" />
                                </Listeners>
                                <CustomConfig>
                                    <ext:ConfigItem Name="endDateField" Value="#{DateField2}" Mode="Value" />
                                </CustomConfig>
                            </ext:DateField>
                            <ext:Label ID="Label2" runat="server" Text="&nbsp;至&nbsp;">
                            </ext:Label>
                            <ext:DateField ID="drTo" runat="server" Vtype="daterange" AnchorHorizontal="100%" Format="yyyy-MM-dd">
                                <Listeners>
                                    <Render Handler="item.setValue(_rangeend);" />
                                    <Change Handler="_rangeend = newValue;" />
                                </Listeners>
                                <CustomConfig>
                                    <ext:ConfigItem Name="startDateField" Value="#{DateField1}" Mode="Value" />
                                </CustomConfig>
                            </ext:DateField>
                            <ext:Button ID="btnReload" runat="server" Text="刷新" Icon="Reload">
                                <Listeners>
                                    <Click Handler="debugger;" />
                                </Listeners>
                            </ext:Button>--%>
                        </Items>
                    </ext:Toolbar>
                </TopBar>
                <Content>
                    <script type="text/javascript">
                        var chart;
                        $(document).ready(function () {
                            chart = new Highcharts.Chart({
                                chart: {
                                    renderTo: 'container',
                                    defaultSeriesType: 'column',
                                    margin: [50, 50, 100, 80]
                                },
                                title: {
                                    text: [formatCNDate(_rangestart), '至 ', formatCNDate(_rangeend), _currenrUserName + '的业务量统计'].join(' ')
                                },
                                xAxis: {
                                    categories: acategories,
                                    labels: {
                                        rotation: -45,
                                        align: 'right',
                                        style: {
                                            font: 'normal 13px Verdana, sans-serif'
                                        }
                                    }
                                },
                                yAxis: {
                                    min: 0,
                                    title: {
                                        text: '业务宗数（宗）'
                                    }
                                },
                                legend: {
                                    enabled: false
                                },
                                tooltip: {
                                    formatter: function () {
                                        return '<b>' + this.x + '</b><br/>' +
								 '一审: ' + Highcharts.numberFormat(this.y, 1) +
								 ' 宗';
                                    }
                                },
                                series: [{
                                    name: '一审',
                                    data: alevel1data, //[10, 20, 30, 40, 50, 60],
                                    dataLabels: {
                                       enabled: true,
                                        rotation: -90,
                                        color: '#FFFFFF',
                                        align: 'right',
                                        x: -6,
                                        y: 10,
                                        formatter: function () {
                                            return this.y;
                                        },
                                        style: {
                                            font: 'normal 13px Verdana, sans-serif'
                                        }
                                    }
                                }],
                                credits: {
                                    enabled: false
                                }
                            });
                        });
                    </script>
                    <div id="container" style="width: 100%; height: 510px; margin: 0 auto">
                    </div>
                </Content>
            </ext:Panel>
        </Items>
    </ext:Viewport>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="HeaderArea" runat="server">
    <script type="text/javascript" src="/content/jquery.min.js"></script>
    <script type="text/javascript" src="/content/highcharts.js"></script>
    <script type="text/javascript" src="/content/modules/exporting.js"></script>
    <script type="text/javascript" language="javascript">
        //var _range = 1;
        function formatCNDate(indate) {
            return [indate.getFullYear(), '年', indate.getMonth() + 1, '月', indate.getDate(), '日'].join('');
        }
    </script>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="StartupArea" runat="server">
</asp:Content>
